Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for embeddings #110

Merged
merged 2 commits into from
Mar 4, 2024
Merged

Conversation

deathbeam
Copy link
Collaborator

@deathbeam deathbeam commented Mar 2, 2024

Closes #5

How it works:

  1. Grabs outline for all functions for all currently opened buffers
  2. Generates embeddings for all the functions
  3. Generates embedding from current code selection
  4. Uses spatial cosine distance to find similar embeddings to code selection
  5. Sends top x matched embeddings as part of the query to copilot in format:
query
File: `<filename1>`
```<filetype_for_filename1>
<embeddings_for_filename1>
```
File: `<filename2>`
```<filetype_for_filename2>
<embeddings_for_filename2>
```
etc

TODO:

  • Embed all open buffers
  • Embed current buffer
  • Limit based on token count (wait for tiktoken lua)
  • Add config options of what should be embedded

Example

image

image

Outline debugging (inside of CopilotChatDebugInfo):

image

Context selection

image

@deathbeam deathbeam added the enhancement New feature or request label Mar 2, 2024
@deathbeam deathbeam force-pushed the embeddings branch 8 times, most recently from 2751494 to 07b089d Compare March 2, 2024 19:39
@deathbeam
Copy link
Collaborator Author

Added code for generating only outline as well, atm unused just being printed to console

@deathbeam
Copy link
Collaborator Author

Ok the draft now uses outline and grabs data for all open buffers

@deathbeam deathbeam force-pushed the embeddings branch 18 times, most recently from b726025 to 606b4ac Compare March 3, 2024 13:39
@deathbeam deathbeam force-pushed the embeddings branch 2 times, most recently from 77d021a to a894b1f Compare March 3, 2024 13:49
@deathbeam deathbeam changed the title Add support for embeddings feat: Add support for embeddings Mar 3, 2024
@deathbeam deathbeam force-pushed the embeddings branch 9 times, most recently from eae639c to 91e38dd Compare March 4, 2024 00:24
@deathbeam deathbeam marked this pull request as ready for review March 4, 2024 00:25
@deathbeam deathbeam force-pushed the embeddings branch 4 times, most recently from 582a781 to 72af025 Compare March 4, 2024 00:44
lua/CopilotChat/context.lua Outdated Show resolved Hide resolved
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
@jellydn jellydn merged commit 9cb8a84 into CopilotC-Nvim:canary Mar 4, 2024
1 check passed
@deathbeam deathbeam deleted the embeddings branch March 4, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants